<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Register extends MY_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function index()
	{
	}
		function basic(){		
	
		//echo test_method();

		if($this->session->userdata("USER_ID")){
			redirect("member/home");
		}
	//	echo uniqueid();	
		$this->form_validation->set_error_delimiters('<label class="label label-important">', '</label>');
		$this->form_validation->set_ruless('profile','Profile created by', 'trim|required',$this->input->post('profilebtn'));
		$this->form_validation->set_ruless('fname','First Name', 'trim|required',$this->input->post('fname'));		
		$this->form_validation->set_ruless('lname','Last Name', 'trim|required',$this->input->post('lname'));
		$this->form_validation->set_ruless('gender','Gender', 'trim|required',$this->input->post('gender'));
		$this->form_validation->set_ruless('day','Date Of Birth', 'trim|required',$this->input->post('day'));
		$this->form_validation->set_ruless('month','Date Of Birth', 'trim|required',$this->input->post('month'));
		$this->form_validation->set_ruless('year','Date Of Birth', 'trim|required',$this->input->post('year'));
		$this->form_validation->set_ruless('heightFeet','Height', 'trim|required',$this->input->post('heightFeet'));		
		$this->form_validation->set_ruless('mob_phone','Mobile', 'trim|required',$this->input->post('mob_phone'));		
		$this->form_validation->set_ruless('maritalStatus','Marital Status', 'trim|required',$this->input->post('maritalStatus'));
		$this->form_validation->set_ruless('email','Email', 'trim|required|valid_email|callback_email_check',$this->input->post('email'));
		$this->form_validation->set_ruless('password','Password', 'trim|required',$this->input->post('password'));
				
		$vewArray = $this->form_validation->error_arrayui();
		if ($this->form_validation->run() == FALSE){
			$vewArray = $this->form_validation->error_arrayui();
		}else{
			$this->model_member->registration();
			$this->session->set_flashdata('message', 'Successfully registerrd your account');
			redirect("");
		}

		# Profile created by
		$this->model_member->getAllm_actcreatedby();		
		$vewArray["html_actcreatedby"] = '';
	
		foreach($this->model_member->queries->result() as $row){
			
		if($this->input->get_post('profile')==$row->id){
			$vewArray["html_actcreatedby"] .= '	   <label>
                  <input type="radio" name="profile" checked="checked"  value="'.$row->id.'" id="RadioGroup1_0" />
                 '.$row->name.'</label>';}
		else{
			$vewArray["html_actcreatedby"] .= '	   <label>
                  <input type="radio" name="profile"  value="'.$row->id.'" id="RadioGroup1_0" />
                 '.$row->name.'</label>';
			}
		
		
		}
		# Date of BIrth
		$vewArray["birth_date"]	   =	get_select_day($this->input->post('day'));
		$vewArray["birth_month"]   =	get_select_month($this->input->post('month'));
		$vewArray["birth_year"]    =	get_select_year($this->input->post('year'));
		
		# Height 
		$vewArray["heightFeet"]    =	get_select_height($this->input->post('heightFeet'));	
		# M status
		$this->model_member->getAllm_maritalstatus();
		$vewArray["html_maritalstatus"] = '';
		$m_status_post = $this->input->post('maritalStatus');
		if($m_status_post!='')
			$m_status = $this->input->post('maritalStatus');
		else
			$m_status =1;
		foreach($this->model_member->queries->result() as $row){
			if($m_status == $row->id)
				$m_status_checkd = 'checked="true"';
			else
				$m_status_checkd = '';
			$vewArray["html_maritalstatus"] .= '<input type="radio" class="radiolabel" '.$m_status_checkd.' id="maritalStatus" name="maritalStatus" value="'.$row->id.'" >
			&nbsp;
			<label class="radiolabel" id="lblprofile1" for="maritalStatus">'.$row->name.'</label>';
		}
		# Religion  
		$vewArray["religion"]      = get_select_box('m_religion','');
		
		# Cast  
		$vewArray["cast"]          = get_select_box('m_cast','');
		
		# Location
		$vewArray["country_living"] = $this->model_location->get_location($location='country',$id=0);
		
		$view_arr["state"]    = $this->model_location->get_state($living_country=69,$living_state='');
		# Mother Tongue
		
		$vewArray["mother_tongue"] = get_select_box('m_mothertongue',$id='');
		
		
		
		
		$this->page("register",$vewArray);

	}
}